import request from '@/utils/request';

// 新增训练任务
export function addTrainingTask(flTrainingTask) {
  return request({
    url: '/fltrainingtask/add',
    method: 'post',
    data: flTrainingTask
  });
}

// 删除训练任务
export function deleteTrainingTask(taskId) {
  return request({
    url: `/fltrainingtask/delete/${taskId}`,
    method: 'delete'
  });
}

// 更新训练任务信息
export function updateTrainingTask(flTrainingTask) {
  return request({
    url: '/fltrainingtask/update',
    method: 'post',
    data: flTrainingTask
  });
}

// 根据 ID 查询训练任务
export function getTrainingTaskById(taskId) {
  return request({
    url: `/fltrainingtask/selectById/${taskId}`,
    method: 'get'
  });
}

// 查询所有训练任务
export function getAllTrainingTasks(flTrainingTask) {
  return request({
    url: '/fltrainingtask/selectAll',
    method: 'get',
    params: flTrainingTask
  });
}

// 分页查询训练任务
export function getTrainingTasksByPage(flTrainingTask, pageNum = 1, pageSize = 10) {
  return request({
    url: '/fltrainingtask/selectPage',
    method: 'get',
    params: {
      ...flTrainingTask,
      pageNum,
      pageSize
    }
  });
}